import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../main.dart';
import '../page/setting_common_page.dart';
import '../page/setting_page.dart';

appBar({bool isIndex = false, String bg = 'bar_bg'}){
  return Container(
      width: double.infinity,
      height: 40.h,
      decoration: BoxDecoration(
        image: DecorationImage(
          fit: BoxFit.fill,
          image: AssetImage(
            "assets/images/$bg.png",
          ),
        ),
      ),
      padding: EdgeInsets.only(left: 8.r,right: 8.r),
      alignment: Alignment.center,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
          Text(settingEntity.deviceName??'轩毅',style: TextStyle(fontSize: 12.sp,color: Colors.white),),
          InkWell(
            onLongPress:(){
              if(isIndex){
                Get.to(()=>const Setting());
              }
            },
            child:  Obx(() => IntrinsicHeight(child: Row(
              children: [
                Text(clock.time.value,style: TextStyle(fontSize: 14.sp,color: Colors.white),),
                VerticalDivider(color: Colors.white,thickness: 1.w,indent:4,endIndent: 4,),
                Text('${clock.day.value}\n${clock.weekDay.value}',style: TextStyle(fontSize: 6.sp,color: Colors.white),),
              ],
            ))),
          ),
        ],
      )
  );
}

